package com.liser.material.design.hardware;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.text.TextUtils;

import com.inuker.bluetooth.library.BluetoothClient;

/**
 * @author LISER
 * @date 2019/12/28 23:54
 */
public class BluetoothClientFactory {

    /**
     * 低功耗蓝牙
     */
    private static BluetoothClient bluetoothClient;

    /**
     * 经典蓝牙
     */
    private static ClassicBluetoothClient classicBluetoothClient;

    /**
     * 蓝牙适配器
     */
    private static BluetoothAdapter mBluetoothAdapter;

    public static BluetoothClient getBluetoothClient(Context context) {
        if (bluetoothClient == null) {
            bluetoothClient = new BluetoothClient(context);
        }
        return bluetoothClient;
    }

    public static ClassicBluetoothClient getClassicBluetoothClient() {
        if (classicBluetoothClient == null) {
            classicBluetoothClient = new ClassicBluetoothClient();
        }
        return classicBluetoothClient;
    }

    public static BluetoothAdapter getBluetoothAdapter() {
        if (mBluetoothAdapter == null) {
            mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        }
        return mBluetoothAdapter;
    }

    public static BluetoothDevice getRemoteDevice(String mac) {
        if (!TextUtils.isEmpty(mac)) {
            BluetoothAdapter adapter = getBluetoothAdapter();
            if (adapter != null) {
                return adapter.getRemoteDevice(mac);
            }
        }
        return null;
    }
}
